//
//  NewsListCell.swift
//  SCA
//
//  Created by tjun on 2025/9/14.
//

import UIKit

class NewsListCell: BaseTableViewCell {
    
    private let dateLabel = UILabel(font: UIFontMake(12), textColor: UIColorMake(0x919191))
    private let titleLabel = UILabel(font: UIFontMediumMake(16), textColor: .systemBlue)
    
    var model: NewsListModel! {
        didSet {
            titleLabel.text = model.title
            dateLabel.text = model.date
            if model.pageType == .news {
                titleLabel.textColor = Assets.Color.newsTitle
            } else {
                titleLabel.textColor = Assets.Color.guideTitle
            }
        }
    }
 
    override func setSubView() {
        super.setSubView()
        
        self.backgroundColor = AppStyle.color.background
        self.selectedBackgroundView = UIView()
        selectCellBackgroundColor = Assets.Color.selectCellBackgroundColor
        
        dateLabel.addTo(contentView)
        dateLabel.numberOfLines = 0
        dateLabel.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(16)
            make.top.equalToSuperview().inset(16)
        }
        
        titleLabel.addTo(contentView)
        titleLabel.numberOfLines = 0
        titleLabel.snp.makeConstraints { make in
            make.left.right.equalTo(dateLabel)
            make.top.equalTo(dateLabel.snp.bottom).offset(8)
        }
        
        let lineView = UIView().addTo(contentView)
        lineView.backgroundColor = UIColor.gray.withAlphaComponent(0.2)
        lineView.snp.makeConstraints { make in
            make.left.right.equalTo(titleLabel)
            make.top.equalTo(titleLabel.snp.bottom).offset(16)
            make.bottom.equalToSuperview()
            make.height.equalTo(1)
        }
    }
}
